import { ResultFile } from '@alilc/lowcode-types';

function createResultFile(name: string, ext = 'jsx', content = ''): ResultFile {
  return {
    name,
    ext,
    content,
  };
}


export default function getFile(param: any): [string[], ResultFile] {
  // console.log('param', param);
  const { globalRouter } = param;
  const file = createResultFile(
    'menuConfig',
    'js',
    `
const headerMenuConfig = [];
const asideMenuConfig = [
  {
    name: 'Dashboard',
    path: '/',
    icon: 'smile',
  },
  ${globalRouter.routes
    .map(
      (route: any, index: number) => (index === 0 ? `{
    name: '${route.componentName}',
    path: '/${route.path || route.componentName}',
    icon: 'smile',
  }` : `
  {
    name: '${route.componentName}',
    path: '/${route.path || route.componentName}',
    icon: 'smile',
  }`),
    )
    .join(',')}
];
export { headerMenuConfig, asideMenuConfig };
    `,
  );

  return [['src', 'layouts', 'BasicLayout'], file];
}
